package com.robusta.cityuate.adapters;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.robusta.cityuate.objects.Comment;
import com.robusta.cityuate.ui.CommentItemView;



public class CommentsAdapter extends BaseAdapter {

	private ArrayList<Comment> mEntries = new ArrayList<Comment>();

	private Context mContext;
	int width;

	public CommentsAdapter(Context context, int width) {
		mContext = context;
		this.width = width;
	
	}

	@Override
	public int getCount() {

		return mEntries.size();
	}

	@Override
	public Object getItem(int position) {

		return mEntries.get(position);
	}

	@Override
	public long getItemId(int position) {
		return mEntries.get(position).getId();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		CommentItemView itemView;
		if (convertView == null)
			{itemView = new CommentItemView(mContext, width);
			
			}
		else
			itemView = (CommentItemView) convertView;
		itemView.bindData((Comment) getItem(position));

		return itemView;
	}
	
	public void addItem(Comment comment){
		mEntries.add(comment);
	}
	
	

}
